﻿namespace GGetTestService.Common.ApiResult
{
    public static class ApiResultHelper
    {
        /// <summary>
        /// 操作成功
        /// </summary>
        /// <returns></returns>
        public static ApiResult Success()
        {
            return new ApiResult
            {
                IsSuccess = true,
                Msg = "操作成功",
                Total = 0,
                Data = null
            };
        }

        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ApiResult Success(object data)
        {
            return new ApiResult
            {
                IsSuccess = true,
                Msg = "操作成功",
                Total = 0,
                Data = data
            };
        }

        /// <summary>
        /// 操作成功
        /// </summary>
        /// <param name="data"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public static ApiResult Success(object data, int total)
        {
            return new ApiResult
            {
                IsSuccess = true,
                Msg = "操作成功",
                Total = total,
                Data = data
            };
        }

        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ApiResult Error(string msg)
        {
            return new ApiResult
            {
                IsSuccess = false,
                Msg = msg,
                Total = 0,
                Data = null
            };
        }
    }
}